//
//  MyActiveCollectionViewController.m
//  豆瓣zlw
//
//  Created by lanou3g on 16/1/11.
//  Copyright © 2016年 zlw. All rights reserved.
//

#import "MyActiveCollectionViewController.h"
#import "MineViewControl.h"
#import "DataBase.h"
#import "ActiveModel.h"
#import "Mine_Active_ViewController.h"

@interface MyActiveCollectionViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray *arrAllData;
}

@end

@implementation MyActiveCollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"我的活动";
    
    
    

    [self.HUD hide:YES];
    
    arrAllData = [NSMutableArray array];
    [self setDatas];
  
    
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    
    
    
    // Do any additional setup after loading the view.
}

-(void)setDatas
{
    //打开数据库
    [[DataBase shareData] openData];
    //查询数据
    arrAllData=[[DataBase shareData] selectAllActs];
  
    [[DataBase shareData]closeData];
    [self.tableView reloadData];
   
  
    
}
//实现的代理方法
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [arrAllData count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *fielPath=@"cell_id";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:fielPath];
    if (cell == nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:fielPath];
    }
    
    ActiveModel *mo =arrAllData[indexPath.row];
    
   
    
    cell.textLabel.text = mo.title;
    
  
    return cell;
}
//*************************点击事件******************************
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    Mine_Active_ViewController * VC=[[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"Min_Active"];
     ActiveModel *mo =arrAllData[indexPath.row];
     
    VC.actModel  = mo;

    [self.navigationController pushViewController:VC animated:YES];
    
 }







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
